package org.btik.light.mobile.meta.mo;


import org.btik.light.meta.DevArea;
import org.btik.light.meta.DevMo;
import org.btik.light.meta.DevState;
import org.btik.light.mobile.meta.DevPanelType;
import org.btik.light.mobile.meta.VideoChannelType;

public class DefaultDevMo extends DevMo {
    private String displayName;

    private DevPanelType devPanelType;

    private DevArea devArea;

    private VideoChannelType videoChannelType;

    public DefaultDevMo(String sn, DevState devState) {
        super(sn, devState);
    }

    public String getDisplayName() {
        if (displayName != null) {
            return displayName;
        }
        String displayName = extendedAttributes.get("displayName");
        if (displayName != null) {
            setDisplayName(displayName);
            return displayName;
        }
        displayName = getDevType();
        if (devType != null) {
            setDisplayName(displayName);
            return displayName;
        }
        return getSn();
    }

    public String getAttr(String name) {
        return extendedAttributes.get(name);
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }


    public DevPanelType getDevPanelType() {
        return devPanelType;
    }

    public void setDevPanelType(DevPanelType devPanelType) {
        this.devPanelType = devPanelType;
    }

    public DevArea getDevArea() {
        return devArea;
    }

    public VideoChannelType getVideoChannelType() {
        return videoChannelType;
    }

    public void setDevArea(DevArea devArea) {
        this.devArea = devArea;
        if (devArea == DevArea.LOCAL) {
            this.videoChannelType = VideoChannelType.ONE_FRAME_VIDEO_CHANNEL;
        } else {
            this.videoChannelType = VideoChannelType.MULTI_SEGMENTED_VIDEO_CHANNEL;
        }
    }

    @Override
    public String toString() {
        return getDisplayName();
    }
}
